import {createRouter, createWebHistory, RouteRecordRaw} from 'vue-router';
import Login from "@/views/user/login/index.vue";
import Authorize from "@/views/oauth/authorize";
import DefaultLayout from "@/layout/DefaultLayout.vue";
import Welcome from "@/views/welcome";
import UserStatus from "@/views/user/userStatus";
import AuthorizationCode from "@/views/authorize/authorizationCode";

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: '',
    meta: {
      title: "授权服务器",
    },
    redirect: "/login",
  },
  {
    path: '/login',
    name: 'login',
    component: Login,
    meta: {
      title: "登录",
    },
  },
  {
    path: '/oauth/authorize',
    name: 'authorize',
    component: Authorize,
    meta: {
      title: "授权",
    },
  },
  {
    path: '/welcome',
    name: 'welcome',
    component: DefaultLayout,
    children: [
      {
        path: '/welcome',
        name: 'welcome',
        component: Welcome,
        meta: {
          title: "欢迎",
        },
      },
    ]
  },
  {
    path: '/backstage',
    name: 'backstage',
    component: DefaultLayout,
    children: [
      {
        path: '/user',
        name: 'user',
        meta: {
          title: "用户管理",
        },
        redirect: "/user/userStatus",
        children: [
          {
            path: '/user/userStatus',
            name: 'userStatus',
            component: UserStatus,
            meta: {
              title: "用户状态",
            },
          },
        ]
      },
      {
        path: '/auth',
        name: 'auth',
        meta: {
          title: "授权管理",
        },
        redirect: "/auth/authorizationCode",
        children: [
          {
            path: '/auth/authorizationCode',
            name: 'authorizationCode',
            component: AuthorizationCode,
            meta: {
              title: "授权码管理",
            },
          },
        ]
      },
    ]
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
